﻿Imports ACompany.OrderProcessing.Infrastructure
Imports NHibernate

Public Class QueryTranslator

    Public Shared Function GetCriteriaFrom(ByVal Criteria As ICriteria, ByVal Query As Query) As ICriteria

        For Each c As Criteria In Query.Criteria

            Select Case c.CriteriaOperator

                Case CriteriaOperator.Equals

                    Criteria.Add(Criterion.Expression.Eq(c.PropertyName, c.Value))

                Case CriteriaOperator.Like
                    Criteria.Add(Criterion.Expression.Like(c.PropertyName, String.Format("{0}%", c.Value)))

                    ' I would add more criteria options
                    ' here as and when I need them
            End Select

        Next

        Return Criteria

    End Function

End Class